import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/login/Login'
import Video from "@/views/video/Video";
import VideoList from "@/views/video/VideoList";
import Register from "@/views/register/Register";
import Chat from "@/views/chat/Chat";
import Index from "@/views/index/Index";
import Question from "@/views/question/Question";
import Gpt from "@/views/chat/gpt";
import Message from "@/views/manage/Message";
import Manage from "@/views/manage/Manage";
import IP from "@/views/manage/IP";
import PersonSpace from "@/views/user/PersonSpace";
import DiseaseInfo from "@/views/disease/DiseaseInfo";
import Disease from "@/views/disease/Disease";
// import store from '@/store'

Vue.use(VueRouter)



//保存原型对象push
let originPush = VueRouter.prototype.push;
let originReplace = VueRouter.prototype.replace;
//重写push|replace
VueRouter.prototype.push = function (location, resolve, reject) {
  if (resolve && reject) {
    originPush.call(this, location, resolve, reject);
  } else {
    originPush.call(this, location, () => {}, () => {});
  }
}
VueRouter.prototype.replace = function (location,resolve,reject){
  if (resolve && reject){
    originReplace.call(this,location,resolve,reject);
  }else {
    originReplace.call(this,location,()=>{},()=>{});
  }
}

let router = new VueRouter({
  routes: [
    {
      path: '/',
      name: 'Index',
      component: Index,
      // meta: {show: false,header:true,Eheader:false}
    },
    {
      path: '/videoList',
      name: 'VideoList',
      component: VideoList,
      // meta: {show: false,header:true,Eheader:false}
    },
    {
      path: '/video/:vod_id',
      name: 'Video',
      component: Video,
      // meta: {show: false,header:true,Eheader:false},
      props: true
    },
    {
      path: '/login',
      name: 'Login',
      component: Login,
      // meta: {show: false,header:true,Eheader:false}
    },
    {
      path: '/register',
      name: 'Register',
      component: Register,
      // meta: {show: false,header:true,Eheader:false}
    },
    {
      path: '/chat',
      name: 'Chat',
      component: Chat,
      meta: { keepAlive: true }
      // meta: {show: false,header:true,Eheader:false}
    },
    {
      path: '/question',
      name: 'Question',
      component: Question,
      // meta: {show: false,header:true,Eheader:false}
    },
    {
      path: '/gpt',
      name: 'GPT',
      component: Gpt,
      // meta: {show: false,header:true,Eheader:false}
    },
    {
      path: '/manage',
      name: 'Manage',
      component: Manage,
      // meta: {show: false,header:true,Eheader:false}
    },
    {
      path: '/message',
      name: 'Message',
      component: Message,
      // meta: {show: false,header:true,Eheader:false}
    },
    {
      path: '/ip',
      name: 'IP',
      component: IP,
      // meta: {show: false,header:true,Eheader:false}
    },
    {
      path: '/personSpace/:uid',
      name: 'PersonSpace',
      component: PersonSpace,
      // meta: {show: false,header:true,Eheader:false}
    },
    {
      path: '/diseaseInfo',
      name: 'DiseaseInfo',
      component: DiseaseInfo,
      // meta: {show: false,header:true,Eheader:false}
    },
    {
      path: '/disease',
      name: 'Disease',
      component: Disease,
      // meta: {show: false,header:true,Eheader:false}
    },
  ]
})

export default router
